import {deleteItemFromCart, getCartByUsername} from "../../../src/api/api";
let nowUsername= sessionStorage.getItem("nowUsername");
export default {
  data(){
    return{
      allOrderPrice : 0,
      checkOrderList:[

      ]
    }
  },
  mounted() {
    this.getCheckOrderList();
  },
  methods:{
    getCheckOrderList() {
      getCartByUsername(nowUsername= sessionStorage.getItem("nowUsername")).then((res) =>{
        console.log(res);
        console.log(res.data);
        this.checkOrderList = res.data.data;
        for(var i = 0;i < this.checkOrderList.length;i++){
          this.allOrderPrice += this.checkOrderList[i].total;
        }
        // for (let i = 0; i < res.data.data.length; i++){
        //   this.cartList[i]['productId'] = res.data.data[i].productId;
        //   this.cartList[i]['categoryId'] = res.data.data[i].categoryId;
        // }
      })
    },
    removeItem(itemId){
      deleteItemFromCart(nowUsername).then((res)=>{
        this.getCartList();
      })
    }
  }
}
